var can1;
var can2;

var ctx1;
var ctx2;
var canWidth;
var canHeight;
var lastTime;
var deltaTime;
var bgimg = new Image();
var xh;
var lw;
var yb;
var mx;
var my;
var wt;
var fz;
var asd=[];
var dui = [];
var cuo = [];
document.body.onload = game;
function game()
{
	init();
	lastTime=Date.now();
	deltaTime=0;
	gameloop();
	
}

function init()
{
	can1=document.getElementById("canvas1");
	ctx1=can1.getContext('2d');
	can2=document.getElementById("canvas2");
	ctx2=can2.getContext('2d');
 
    can1.addEventListener('mousemove',onMouseMove,false);
 
	canWidth=can1.width;
	canHeight=can1.height;
	bgimg.src="SRC/111.jpg";
	xh=new xhobj();
	xh.init();
	lw = new lwobj();
	lw.init();
    yb = new ybobj();
	yb.init();
	wt = new wtobj();
	
	mx = canWidth*0.5;
	my = canHeight*0.5;
	
	
	
	fz = new fzobj();
	
	for(var i = 8;i<16;i++)
	{

		var zz = new Image();
		zz.src="SRC/"+i+".png";
		asd.push(zz);
		
	}
	for(var i = 1;i<10;i++)
	{

		var zz = new Image();
		zz.src="SRC/dui"+i+".png";
		dui.push(zz);
		
	}
	for(var i = 1;i<14;i++)
	{

		var zz = new Image();
		zz.src="SRC/cuo"+i+".png";
		cuo.push(zz);
		
	}
}

function gameloop()
{
	window.requestAnimFrame(gameloop);
	
	var now = Date.now();
	deltaTime = now - lastTime;
	lastTime = now ;
    
	if(deltaTime > 40)deltaTime=40;
	
	drawBackground();
	xh.draw();
    lwMonitor();
	lw.draw();
	ctx1.clearRect(0,0,canWidth,canHeight);
	yb.draw();
	ybpz();
	fz.draw();
	

}
function onMouseMove(e)
{
	if(e.offSetX||e.layerX)
	{
		mx = e.offSetX == undefined?e.layerX:e.offSetX;
		my = e.offSetY == undefined?e.layerY:e.offSetY;
		
		}
	}